
# make 编译并下载
# make VERBOSE=1 显示编译详细过程
# make clean 清除编译临时文件
#
# 注意： Linux 下编译方式：
#     1. 从 http://pkgman.jieliapp.com/doc/all 处找到下载链接
#     2. 下载后，解压到 /opt/jieli 目录下，保证
#       /opt/jieli/common/bin/clang 存在（注意目录层次）
#     3. 确认 ulimit -n 的结果足够大（建议大于8096），否则链接可能会因为打开文件太多而失败
#       可以通过 ulimit -n 8096 来设置一个较大的值
#

# 工具路径设置
ifeq ($(OS), Windows_NT)
# Windows 下工具链位置
TOOL_DIR := C:/JL/pi32/bin
CC    := clang.exe
CXX   := clang.exe
LD    := pi32v2-lto-wrapper.exe
AR    := pi32v2-lto-ar.exe
MKDIR := mkdir_win -p
RM    := rm -rf

SYS_LIB_DIR := C:/JL/pi32/pi32v2-lib/r3
SYS_INC_DIR := C:/JL/pi32/pi32v2-include
EXT_CFLAGS  := # Windows 下不需要 -D__SHELL__
export PATH:=$(TOOL_DIR);$(PATH)

## 后处理脚本
FIXBAT          := tools\utils\fixbat.exe # 用于处理 utf8->gbk 编码问题
POST_SCRIPT     := cpu\br25\tools\download.bat
RUN_POST_SCRIPT := $(POST_SCRIPT)
else
# Linux 下工具链位置
TOOL_DIR := /opt/jieli/pi32v2/bin
CC    := clang
CXX   := clang++
LD    := lto-wrapper
AR    := lto-ar
MKDIR := mkdir -p
RM    := rm -rf
export OBJDUMP := $(TOOL_DIR)/objdump
export OBJCOPY := $(TOOL_DIR)/objcopy
export OBJSIZEDUMP := $(TOOL_DIR)/objsizedump

SYS_LIB_DIR := $(TOOL_DIR)/../lib/r3
SYS_INC_DIR := $(TOOL_DIR)/../include
EXT_CFLAGS  := -D__SHELL__ # Linux 下需要这个保证正确处理 download.c
export PATH:=$(TOOL_DIR):$(PATH)

## 后处理脚本
FIXBAT          := touch # Linux下不需要处理 bat 编码问题
POST_SCRIPT     := cpu/br25/tools/download.sh
RUN_POST_SCRIPT := bash $(POST_SCRIPT)
endif

CC  := $(TOOL_DIR)/$(CC)
CXX := $(TOOL_DIR)/$(CXX)
LD  := $(TOOL_DIR)/$(LD)
AR  := $(TOOL_DIR)/$(AR)
# 输出文件设置
OUT_ELF   := cpu/br25/tools/sdk.elf
OBJ_FILE  := $(OUT_ELF).objs.txt
# 编译路径设置
BUILD_DIR := objs

# 编译参数设置
CFLAGS := \
	-target pi32v2 \
	-mcpu=r3 \
	-integrated-as \
	-flto \
	-Wuninitialized \
	-Wno-invalid-noreturn \
	-fno-common \
	-integrated-as \
	-Oz \
	-g \
	-flto \
	-fallow-pointer-null \
	-fprefer-gnu-section \
	-Wno-shift-negative-value \
	-Wundef \
	-fms-extensions \
	-w \


# C++额外的编译参数
CXXFLAGS :=


# 宏定义
DEFINES := \
	-DSUPPORT_MS_EXTENSIONS \
	-DCONFIG_CPU_BR25 \
	-DCONFIG_PRINT_IN_MASK \
	-DCONFIG_RELEASE_ENABLE \
	-DCONFIG_EQ_SUPPORT_ASYNC \
	-DCONFIG_MIXER_CYCLIC \
	-DCONFIG_FREE_RTOS_ENABLE \
	-DSUPPORT_BLUETOOTH_PROFILE_RELEASE \
	-DCONFIG_SOUNDBOX \
	-DEVENT_HANDLER_NUM_CONFIG=2 \
	-DEVENT_TOUCH_ENABLE_CONFIG=0 \
	-DEVENT_POOL_SIZE_CONFIG=256 \
	-DCONFIG_EVENT_KEY_MAP_ENABLE=0 \
	-DTIMER_POOL_NUM_CONFIG=15 \
	-DAPP_ASYNC_POOL_NUM_CONFIG=0 \
	-DVFS_ENABLE=1 \
	-DUSE_SDFILE_NEW=1 \
	-DSDFILE_STORAGE=1 \
	-DVFS_FILE_POOL_NUM_CONFIG=1 \
	-DFS_VERSION=0x020001 \
	-DFATFS_VERSION=0x020101 \
	-DSDFILE_VERSION=0x020000 \
	-DVM_MAX_SIZE_CONFIG=64*1024 \
	-DVM_ITEM_MAX_NUM=256 \
	-DCONFIG_TWS_ENABLE \
	-DCONFIG_SOUNDBOX_CASE_ENABLE \
	-DCONFIG_NEW_CFG_TOOL_ENABLE \
	-DCONFIG_LITE_AEC_ENABLE=0 \
	-DAUDIO_REC_POOL_NUM=1 \
	-DAUDIO_DEC_POOL_NUM=3 \
	-DAUDIO_LOCAL_DEC_USE_MALLOC \
	-DCONFIG_TONE_LOCK_BY_BT_TIME \
	-DCONFIG_LMP_CONN_SUSPEND_ENABLE \
	-DCONFIG_BTCTRLER_TASK_DEL_ENABLE \
	-DCONFIG_LINK_DISTURB_SCAN_ENABLE=0 \
	-DCONFIG_UPDATA_ENABLE \
	-DCONFIG_OTA_UPDATA_ENABLE \
	-DCONFIG_CODE_MOVABLE_ENABLE \
	-DCONFIG_ITEM_FORMAT_VM \
	-DCONFIG_MMU_ENABLE \
	-DCONFIG_SBC_CODEC_HW \
	-DCONFIG_MSBC_CODEC_HW \
	-DCONFIG_AEC_M=256 \
	-DCONFIG_AUDIO_ONCHIP \
	-DCONFIG_MEDIA_DEVELOP_ENABLE \
	-D__GCC_PI32V2__ \
	-DCONFIG_NEW_ECC_ENABLE \


DEFINES += $(EXT_CFLAGS) # 额外的一些定义

# 头文件搜索路径
INCLUDES := \
	-Iinclude_lib \
	-Iinclude_lib/driver \
	-Iinclude_lib/driver/device \
	-Iinclude_lib/driver/cpu/br25 \
	-Iinclude_lib/system \
	-Iinclude_lib/system/generic \
	-Iinclude_lib/system/device \
	-Iinclude_lib/system/fs \
	-Iinclude_lib/system/ui \
	-Iinclude_lib/btctrler \
	-Iinclude_lib/btctrler/port/br25 \
	-Iinclude_lib/update \
	-Iinclude_lib/agreement \
	-Iinclude_lib/btstack/third_party/common \
	-Iinclude_lib/btstack/third_party/rcsp \
	-Iinclude_lib/media/media_develop \
	-Iinclude_lib/media/media_develop/media \
	-Iinclude_lib/media/media_develop/media/cpu/br25 \
	-Iinclude_lib/media/media_develop/media/cpu/br25/asm \
	-Icpu/br25/audio_mic \
	-Iapps/soundbox/include \
	-Iapps/soundbox/include/task_manager \
	-Iapps/soundbox/include/task_manager/bt \
	-Iapps/soundbox/include/user_api \
	-Iapps/common \
	-Iapps/common/device \
	-Iapps/common/audio \
	-Iapps/common/audio/stream \
	-Iapps/common/power_manage \
	-Iapps/common/charge_box \
	-Iapps/common/third_party_profile/common \
	-Iapps/common/third_party_profile/jieli \
	-Iapps/common/third_party_profile/jieli/trans_data_demo \
	-Iapps/common/third_party_profile/jieli/online_db \
	-Iapps/common/third_party_profile/jieli/JL_rcsp \
	-Iapps/common/third_party_profile/jieli/JL_rcsp/rcsp_updata \
	-Iapps/common/third_party_profile/jieli/JL_rcsp/bt_trans_data \
	-Iapps/common/third_party_profile/jieli/JL_rcsp/adv_rcsp_protocol \
	-Iapps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting \
	-Iapps/common/third_party_profile/interface \
	-Iapps/common/dev_manager \
	-Iapps/common/file_operate \
	-Iapps/common/music \
	-Iapps/common/include \
	-Iapps/common/config/include \
	-Iapps/soundbox/board/br25 \
	-Icpu/br25 \
	-Icpu/br25/audio_common \
	-Icpu/br25/audio_dec \
	-Icpu/br25/audio_enc \
	-Icpu/br25/audio_effect \
	-Icpu/br25/localtws \
	-Iinclude_lib/btstack \
	-Iapps/common/usb \
	-Iapps/common/usb/device \
	-Iapps/common/usb/host \
	-Iapps/soundbox/smartbox \
	-Iapps/soundbox/smartbox/bt_manage/bt_trans_data \
	-Iapps/soundbox/smartbox/bt_manage \
	-Iapps/soundbox/smartbox/smartbox_setting \
	-Iapps/soundbox/smartbox/smartbox_setting/smartbox_misc_setting \
	-Iapps/soundbox/smartbox/smartbox_setting_opt \
	-Iapps/soundbox/smartbox/smartbox_update \
	-Iapps/soundbox/smartbox/file_transfer \
	-Iapps/soundbox/smartbox/tuya \
	-Iapps/soundbox/include/ui/color_led \
	-Iapps/common/third_party_profile/tuya_protocol \
	-Iapps/common/third_party_profile/tuya_protocol/app/demo \
	-Iapps/common/third_party_profile/tuya_protocol/app/product_test \
	-Iapps/common/third_party_profile/tuya_protocol/app/uart_common \
	-Iapps/common/third_party_profile/tuya_protocol/extern_components/mbedtls \
	-Iapps/common/third_party_profile/tuya_protocol/port \
	-Iapps/common/third_party_profile/tuya_protocol/sdk/include \
	-Iapps/common/third_party_profile/tuya_protocol/sdk/lib \
	-I$(SYS_INC_DIR) \


# 需要编译的 .c 文件
c_SRC_FILES := \
	apps/common/audio/audio_digital_vol.c \
	apps/common/audio/audio_utils.c \
	apps/common/audio/decode/audio_key_tone.c \
	apps/common/audio/decode/decode.c \
	apps/common/audio/encode/encode_write_file.c \
	apps/common/audio/sine_make.c \
	apps/common/audio/stream/stream_entry.c \
	apps/common/audio/stream/stream_src.c \
	apps/common/audio/stream/stream_sync.c \
	apps/common/audio/uartPcmSender.c \
	apps/common/bt_common/bt_test_api.c \
	apps/common/charge_box/chargeIc_manage.c \
	apps/common/charge_box/chgbox_box.c \
	apps/common/charge_box/chgbox_ctrl.c \
	apps/common/charge_box/chgbox_det.c \
	apps/common/charge_box/chgbox_handshake.c \
	apps/common/charge_box/chgbox_ui.c \
	apps/common/charge_box/chgbox_ui_drv_pwmled.c \
	apps/common/charge_box/chgbox_ui_drv_timer.c \
	apps/common/charge_box/chgbox_wireless.c \
	apps/common/config/app_config.c \
	apps/common/config/bt_profile_config.c \
	apps/common/config/ci_transport_uart.c \
	apps/common/debug/debug.c \
	apps/common/debug/debug_lite.c \
	apps/common/dev_manager/dev_manager.c \
	apps/common/dev_manager/dev_reg.c \
	apps/common/dev_manager/dev_update.c \
	apps/common/device/bmp280/bmp280.c \
	apps/common/device/detection.c \
	apps/common/device/fm/bk1080/Bk1080.c \
	apps/common/device/fm/fm_inside/fm_inside.c \
	apps/common/device/fm/fm_manage.c \
	apps/common/device/fm/qn8035/QN8035.c \
	apps/common/device/fm/rda5807/RDA5807.c \
	apps/common/device/fm_emitter/ac3433/ac3433.c \
	apps/common/device/fm_emitter/fm_emitter_manage.c \
	apps/common/device/fm_emitter/fm_inside/fm_emitter_inside.c \
	apps/common/device/fm_emitter/qn8007/qn8007.c \
	apps/common/device/fm_emitter/qn8027/qn8027.c \
	apps/common/device/gSensor/SC7A20.c \
	apps/common/device/gSensor/da230.c \
	apps/common/device/gSensor/gSensor_manage.c \
	apps/common/device/gps/atk1218_bd.c \
	apps/common/device/max30102/algorithm.c \
	apps/common/device/max30102/max30102.c \
	apps/common/device/nandflash/nandflash.c \
	apps/common/device/norflash/norflash.c \
	apps/common/fat_nor/cfg_private.c \
	apps/common/fat_nor/nor_fs.c \
	apps/common/fat_nor/phone_rec_fs.c \
	apps/common/fat_nor/virfat_flash.c \
	apps/common/file_operate/file_api.c \
	apps/common/file_operate/file_bs_deal.c \
	apps/common/file_operate/file_manager.c \
	apps/common/iap/iAP_des.c \
	apps/common/iap/iAP_device.c \
	apps/common/iap/iAP_iic.c \
	apps/common/key/adkey.c \
	apps/common/key/adkey_rtcvdd.c \
	apps/common/key/ctmu_touch_key.c \
	apps/common/key/iokey.c \
	apps/common/key/irkey.c \
	apps/common/key/key_driver.c \
	apps/common/key/rdec_key.c \
	apps/common/key/slidekey.c \
	apps/common/key/touch_key.c \
	apps/common/music/breakpoint.c \
	apps/common/music/general_player.c \
	apps/common/music/music_decrypt.c \
	apps/common/music/music_id3.c \
	apps/common/music/music_player.c \
	apps/common/rec_nor/nor_interface.c \
	apps/common/rec_nor/nor_rec_fs.c \
	apps/common/third_party_profile/common/3th_profile_api.c \
	apps/common/third_party_profile/common/custom_cfg.c \
	apps/common/third_party_profile/common/mic_rec.c \
	apps/common/third_party_profile/interface/app_protocol_api.c \
	apps/common/third_party_profile/interface/app_protocol_common.c \
	apps/common/third_party_profile/interface/app_protocol_dma.c \
	apps/common/third_party_profile/interface/app_protocol_gma.c \
	apps/common/third_party_profile/interface/app_protocol_mma.c \
	apps/common/third_party_profile/interface/app_protocol_ota.c \
	apps/common/third_party_profile/interface/app_protocol_tme.c \
	apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_bt_name_setting.c \
	apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_key_setting.c \
	apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_led_setting.c \
	apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_mic_setting.c \
	apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_time_stamp_setting.c \
	apps/common/third_party_profile/jieli/JL_rcsp/adv_app_setting/adv_work_setting.c \
	apps/common/third_party_profile/jieli/JL_rcsp/adv_rcsp_protocol/rcsp_adv_opt.c \
	apps/common/third_party_profile/jieli/JL_rcsp/adv_rcsp_protocol/rcsp_adv_tws_sync.c \
	apps/common/third_party_profile/jieli/JL_rcsp/rcsp_updata/rcsp_adv_user_update.c \
	apps/common/third_party_profile/jieli/hid_user.c \
	apps/common/third_party_profile/jieli/le_client_demo.c \
	apps/common/third_party_profile/jieli/multi_demo/le_multi_client.c \
	apps/common/third_party_profile/jieli/multi_demo/le_multi_common.c \
	apps/common/third_party_profile/jieli/multi_demo/le_multi_trans.c \
	apps/common/third_party_profile/jieli/online_db/online_db_deal.c \
	apps/common/third_party_profile/jieli/online_db/spp_online_db.c \
	apps/common/third_party_profile/jieli/trans_data_demo/le_trans_data.c \
	apps/common/third_party_profile/jieli/trans_data_demo/spp_trans_data.c \
	apps/common/third_party_profile/tuya_protocol/app/demo/tuya_ble_app_demo.c \
	apps/common/third_party_profile/tuya_protocol/app/demo/tuya_ota.c \
	apps/common/third_party_profile/tuya_protocol/app/demo/tuya_usertask.c \
	apps/common/third_party_profile/tuya_protocol/app/product_test/tuya_ble_app_production_test.c \
	apps/common/third_party_profile/tuya_protocol/app/uart_common/tuya_ble_app_uart_common_handler.c \
	apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/aes.c \
	apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/ccm.c \
	apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/hmac.c \
	apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/md5.c \
	apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/sha1.c \
	apps/common/third_party_profile/tuya_protocol/extern_components/mbedtls/sha256.c \
	apps/common/third_party_profile/tuya_protocol/port/tuya_ble_port.c \
	apps/common/third_party_profile/tuya_protocol/port/tuya_ble_port_AD697x.c \
	apps/common/third_party_profile/tuya_protocol/port/tuya_ble_port_peripheral.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_api.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_bulk_data.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_data_handler.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_event.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_event_handler.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_event_handler_weak.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_feature_weather.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_gatt_send_queue.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_heap.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_main.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_mem.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_mutli_tsf_protocol.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_queue.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_storage.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_unix_time.c \
	apps/common/third_party_profile/tuya_protocol/sdk/src/tuya_ble_utils.c \
	apps/common/ui/lcd/lcd_ui_api.c \
	apps/common/ui/lcd_simple/lcd_simple_api.c \
	apps/common/ui/lcd_simple/ui.c \
	apps/common/ui/lcd_simple/ui_mainmenu.c \
	apps/common/ui/led7/led7_ui_api.c \
	apps/common/update/norflash_ufw_update.c \
	apps/common/update/norflash_update.c \
	apps/common/update/testbox_update.c \
	apps/common/update/uart_update.c \
	apps/common/update/uart_update_master.c \
	apps/common/update/update.c \
	apps/common/update/update_tws_new.c \
	apps/common/usb/device/cdc.c \
	apps/common/usb/device/descriptor.c \
	apps/common/usb/device/hid.c \
	apps/common/usb/device/msd.c \
	apps/common/usb/device/msd_upgrade.c \
	apps/common/usb/device/task_pc.c \
	apps/common/usb/device/uac1.c \
	apps/common/usb/device/uac_stream.c \
	apps/common/usb/device/usb_device.c \
	apps/common/usb/device/user_setup.c \
	apps/common/usb/host/adb.c \
	apps/common/usb/host/aoa.c \
	apps/common/usb/host/apple_mfi.c \
	apps/common/usb/host/audio.c \
	apps/common/usb/host/audio_demo.c \
	apps/common/usb/host/hid.c \
	apps/common/usb/host/usb_bulk_transfer.c \
	apps/common/usb/host/usb_ctrl_transfer.c \
	apps/common/usb/host/usb_host.c \
	apps/common/usb/host/usb_storage.c \
	apps/common/usb/usb_config.c \
	apps/common/usb/usb_host_config.c \
	apps/soundbox/aec/br25/audio_aec.c \
	apps/soundbox/app_main.c \
	apps/soundbox/board/br25/board_ac6366c_chargebox_inside/board_ac6366c_chargebox_inside.c \
	apps/soundbox/board/br25/board_ac6366c_chargebox_inside/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac6366c_chargebox_inside/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac6366c_chargebox_inside/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac6366c_chargebox_inside/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac6366c_chargebox_inside/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_inside/board_ac636x_chargebox_inside.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_inside/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_inside/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_inside/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_inside/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_inside/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_outside/board_ac636x_chargebox_outside.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_outside/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_outside/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_outside/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_outside/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac636x_chargebox_outside/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac6969d_demo/board_ac6969d_demo.c \
	apps/soundbox/board/br25/board_ac6969d_demo/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac6969d_demo/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac6969d_demo/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac6969d_demo/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac6969d_demo/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_audio_effects/board_ac696x_audio_effects.c \
	apps/soundbox/board/br25/board_ac696x_audio_effects/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_audio_effects/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_audio_effects/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_audio_effects/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_audio_effects/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_btbox/board_ac696x_btbox.c \
	apps/soundbox/board/br25/board_ac696x_btbox/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_btbox/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_btbox/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_btbox/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_btbox/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_btemitter/board_ac696x_btemitter.c \
	apps/soundbox/board/br25/board_ac696x_btemitter/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_btemitter/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_btemitter/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_btemitter/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_btemitter/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_demo/board_ac696x_demo.c \
	apps/soundbox/board/br25/board_ac696x_demo/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_demo/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_demo/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_demo/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_demo/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_lcd/board_ac696x_lcd.c \
	apps/soundbox/board/br25/board_ac696x_lcd/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_lcd/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_lcd/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_lcd/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_lcd/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_lighter/board_ac696x_lighter.c \
	apps/soundbox/board/br25/board_ac696x_lighter/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_lighter/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_lighter/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_lighter/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_lighter/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_megaphone/board_ac696x_megaphone.c \
	apps/soundbox/board/br25/board_ac696x_megaphone/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_megaphone/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_megaphone/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_megaphone/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_megaphone/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_smartbox/board_ac696x_smartbox.c \
	apps/soundbox/board/br25/board_ac696x_smartbox/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_smartbox/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_smartbox/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_smartbox/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_smartbox/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_tws/board_ac696x_tws.c \
	apps/soundbox/board/br25/board_ac696x_tws/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_tws/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_tws/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_tws/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_tws/key_table/touch_key_table.c \
	apps/soundbox/board/br25/board_ac696x_tws_box/board_ac696x_tws_box.c \
	apps/soundbox/board/br25/board_ac696x_tws_box/key_table/adkey_table.c \
	apps/soundbox/board/br25/board_ac696x_tws_box/key_table/iokey_table.c \
	apps/soundbox/board/br25/board_ac696x_tws_box/key_table/irkey_table.c \
	apps/soundbox/board/br25/board_ac696x_tws_box/key_table/rdec_key_table.c \
	apps/soundbox/board/br25/board_ac696x_tws_box/key_table/touch_key_table.c \
	apps/soundbox/common/app_sound_box_tool.c \
	apps/soundbox/common/dev_status.c \
	apps/soundbox/common/init.c \
	apps/soundbox/common/task_table.c \
	apps/soundbox/common/tone_table.c \
	apps/soundbox/common/user_cfg_new.c \
	apps/soundbox/font/fontinit.c \
	apps/soundbox/log_config/app_config.c \
	apps/soundbox/log_config/lib_btctrler_config.c \
	apps/soundbox/log_config/lib_btstack_config.c \
	apps/soundbox/log_config/lib_driver_config.c \
	apps/soundbox/log_config/lib_media_config.c \
	apps/soundbox/log_config/lib_system_config.c \
	apps/soundbox/log_config/lib_update_config.c \
	apps/soundbox/power_manage/app_charge.c \
	apps/soundbox/power_manage/app_chargestore.c \
	apps/soundbox/power_manage/app_power_manage.c \
	apps/soundbox/smartbox/browser/browser.c \
	apps/soundbox/smartbox/bt_manage/bt_trans_data/le_smartbox_adv.c \
	apps/soundbox/smartbox/bt_manage/bt_trans_data/le_smartbox_module.c \
	apps/soundbox/smartbox/bt_manage/smartbox_bt_manage.c \
	apps/soundbox/smartbox/cmd_data_deal/cmd_recieve.c \
	apps/soundbox/smartbox/cmd_data_deal/cmd_recieve_no_respone.c \
	apps/soundbox/smartbox/cmd_data_deal/cmd_respone.c \
	apps/soundbox/smartbox/cmd_data_deal/cmd_user.c \
	apps/soundbox/smartbox/cmd_data_deal/command.c \
	apps/soundbox/smartbox/cmd_data_deal/data_recieve.c \
	apps/soundbox/smartbox/cmd_data_deal/data_recieve_no_respone.c \
	apps/soundbox/smartbox/cmd_data_deal/data_respone.c \
	apps/soundbox/smartbox/config.c \
	apps/soundbox/smartbox/event.c \
	apps/soundbox/smartbox/feature.c \
	apps/soundbox/smartbox/file_transfer/dev_format.c \
	apps/soundbox/smartbox/file_transfer/file_delete.c \
	apps/soundbox/smartbox/file_transfer/file_transfer.c \
	apps/soundbox/smartbox/func_cmd/bt_func.c \
	apps/soundbox/smartbox/func_cmd/fm_func.c \
	apps/soundbox/smartbox/func_cmd/linein_func.c \
	apps/soundbox/smartbox/func_cmd/music_func.c \
	apps/soundbox/smartbox/func_cmd/rtc_func.c \
	apps/soundbox/smartbox/function.c \
	apps/soundbox/smartbox/smartbox.c \
	apps/soundbox/smartbox/smartbox_rcsp_manage.c \
	apps/soundbox/smartbox/smartbox_setting/adv_bt_name_setting.c \
	apps/soundbox/smartbox/smartbox_setting/adv_key_setting.c \
	apps/soundbox/smartbox/smartbox_setting/adv_led_setting.c \
	apps/soundbox/smartbox/smartbox_setting/adv_mic_setting.c \
	apps/soundbox/smartbox/smartbox_setting/adv_time_stamp_setting.c \
	apps/soundbox/smartbox/smartbox_setting/adv_work_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_color_led_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_eq_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_high_low_vol_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_karaoke_eq_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_karaoke_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_misc_setting/smartbox_misc_drc_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_misc_setting/smartbox_misc_reverbration_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_misc_setting/smartbox_misc_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_music_info_setting.c \
	apps/soundbox/smartbox/smartbox_setting/smartbox_vol_setting.c \
	apps/soundbox/smartbox/smartbox_setting_opt/smartbox_adv_bluetooth.c \
	apps/soundbox/smartbox/smartbox_setting_opt/smartbox_setting_opt.c \
	apps/soundbox/smartbox/smartbox_setting_opt/smartbox_setting_sync.c \
	apps/soundbox/smartbox/smartbox_task.c \
	apps/soundbox/smartbox/smartbox_update/rcsp_ch_loader_download.c \
	apps/soundbox/smartbox/smartbox_update/smartbox_update.c \
	apps/soundbox/smartbox/smartbox_update/smartbox_update_tws.c \
	apps/soundbox/smartbox/switch_device.c \
	apps/soundbox/smartbox/tuya/tuya_demo.c \
	apps/soundbox/soundcard/lamp.c \
	apps/soundbox/soundcard/notice.c \
	apps/soundbox/soundcard/peripheral.c \
	apps/soundbox/soundcard/soundcard.c \
	apps/soundbox/task_manager/app_common.c \
	apps/soundbox/task_manager/app_task_switch.c \
	apps/soundbox/task_manager/bt/bt.c \
	apps/soundbox/task_manager/bt/bt_ble.c \
	apps/soundbox/task_manager/bt/bt_emitter.c \
	apps/soundbox/task_manager/bt/bt_event_fun.c \
	apps/soundbox/task_manager/bt/bt_key_fun.c \
	apps/soundbox/task_manager/bt/bt_product_test.c \
	apps/soundbox/task_manager/bt/bt_switch_fun.c \
	apps/soundbox/task_manager/bt/bt_tws.c \
	apps/soundbox/task_manager/bt/bt_vartual_fast_connect.c \
	apps/soundbox/task_manager/bt/vol_sync.c \
	apps/soundbox/task_manager/fm/fm.c \
	apps/soundbox/task_manager/fm/fm_api.c \
	apps/soundbox/task_manager/fm/fm_rw.c \
	apps/soundbox/task_manager/idle/idle.c \
	apps/soundbox/task_manager/linein/linein.c \
	apps/soundbox/task_manager/linein/linein_api.c \
	apps/soundbox/task_manager/linein/linein_dev.c \
	apps/soundbox/task_manager/music/music.c \
	apps/soundbox/task_manager/pc/pc.c \
	apps/soundbox/task_manager/power_off/power_off.c \
	apps/soundbox/task_manager/power_on/power_on.c \
	apps/soundbox/task_manager/record/record.c \
	apps/soundbox/task_manager/rtc/alarm_api.c \
	apps/soundbox/task_manager/rtc/alarm_user.c \
	apps/soundbox/task_manager/rtc/rtc.c \
	apps/soundbox/task_manager/rtc/virtual_rtc.c \
	apps/soundbox/task_manager/sleep/sleep.c \
	apps/soundbox/task_manager/spdif/hdmi_cec_drv.c \
	apps/soundbox/task_manager/spdif/spdif.c \
	apps/soundbox/task_manager/task_key.c \
	apps/soundbox/third_party_profile/ancs_client_demo/ancs_client_demo.c \
	apps/soundbox/third_party_profile/app_protocol_deal.c \
	apps/soundbox/third_party_profile/trans_data_demo/trans_data_demo.c \
	apps/soundbox/ui/color_led/color_led_app.c \
	apps/soundbox/ui/color_led/color_led_table.c \
	apps/soundbox/ui/color_led/driver/color_led.c \
	apps/soundbox/ui/color_led/driver/color_led_driver.c \
	apps/soundbox/ui/lcd/STYLE_02/bt_action.c \
	apps/soundbox/ui/lcd/STYLE_02/clock_action.c \
	apps/soundbox/ui/lcd/STYLE_02/file_brower.c \
	apps/soundbox/ui/lcd/STYLE_02/fm_action.c \
	apps/soundbox/ui/lcd/STYLE_02/linein_action.c \
	apps/soundbox/ui/lcd/STYLE_02/music_action.c \
	apps/soundbox/ui/lcd/STYLE_02/record_action.c \
	apps/soundbox/ui/lcd/STYLE_02/system_action.c \
	apps/soundbox/ui/lcd/lyrics_api.c \
	apps/soundbox/ui/lcd/ui_sys_param_api.c \
	apps/soundbox/ui/lcd_simple/my_demo.c \
	apps/soundbox/ui/led/pwm_led_api.c \
	apps/soundbox/ui/led/pwm_led_para_table.c \
	apps/soundbox/ui/led7/ui_bt.c \
	apps/soundbox/ui/led7/ui_common.c \
	apps/soundbox/ui/led7/ui_fm.c \
	apps/soundbox/ui/led7/ui_fm_emitter.c \
	apps/soundbox/ui/led7/ui_idle.c \
	apps/soundbox/ui/led7/ui_linein.c \
	apps/soundbox/ui/led7/ui_music.c \
	apps/soundbox/ui/led7/ui_pc.c \
	apps/soundbox/ui/led7/ui_record.c \
	apps/soundbox/ui/led7/ui_rtc.c \
	apps/soundbox/user_api/app_pwmled_api.c \
	apps/soundbox/user_api/app_record_api.c \
	apps/soundbox/user_api/app_special_play_api.c \
	apps/soundbox/user_api/app_status_api.c \
	apps/soundbox/user_api/dev_multiplex_api.c \
	apps/soundbox/user_api/product_info_api.c \
	apps/soundbox/version.c \
	cpu/br25/adc_api.c \
	cpu/br25/audio_common/app_audio.c \
	cpu/br25/audio_common/audio_iis.c \
	cpu/br25/audio_common/audio_link.c \
	cpu/br25/audio_dec/audio_dec.c \
	cpu/br25/audio_dec/audio_dec_bt.c \
	cpu/br25/audio_dec/audio_dec_file.c \
	cpu/br25/audio_dec/audio_dec_fm.c \
	cpu/br25/audio_dec/audio_dec_linein.c \
	cpu/br25/audio_dec/audio_dec_midi_ctrl.c \
	cpu/br25/audio_dec/audio_dec_midi_file.c \
	cpu/br25/audio_dec/audio_dec_pc.c \
	cpu/br25/audio_dec/audio_dec_record.c \
	cpu/br25/audio_dec/audio_dec_spdif.c \
	cpu/br25/audio_dec/audio_dec_tone.c \
	cpu/br25/audio_dec/audio_spectrum.c \
	cpu/br25/audio_dec/audio_sync.c \
	cpu/br25/audio_dec/audio_usb_mic.c \
	cpu/br25/audio_dec/tone_player.c \
	cpu/br25/audio_demo/audio_cvp_demo.c \
	cpu/br25/audio_demo/audio_fft_demo.c \
	cpu/br25/audio_effect/audio_autotune_demo.c \
	cpu/br25/audio_effect/audio_ch_swap_demo.c \
	cpu/br25/audio_effect/audio_dynamic_eq_demo.c \
	cpu/br25/audio_effect/audio_eff_default_parm.c \
	cpu/br25/audio_effect/audio_eq_drc_demo.c \
	cpu/br25/audio_effect/audio_gain_process_demo.c \
	cpu/br25/audio_effect/audio_noise_gate_demo.c \
	cpu/br25/audio_effect/audio_sound_track_2_p_x.c \
	cpu/br25/audio_effect/audio_surround_demo.c \
	cpu/br25/audio_effect/audio_vbass_demo.c \
	cpu/br25/audio_effect/audio_voice_changer_demo.c \
	cpu/br25/audio_effect/effects_adj.c \
	cpu/br25/audio_effect/eq_config.c \
	cpu/br25/audio_enc/audio_adc_demo.c \
	cpu/br25/audio_enc/audio_cvp.c \
	cpu/br25/audio_enc/audio_dongle_codec.c \
	cpu/br25/audio_enc/audio_enc.c \
	cpu/br25/audio_enc/audio_enc_file.c \
	cpu/br25/audio_enc/audio_enc_recoder.c \
	cpu/br25/audio_enc/audio_mic_codec.c \
	cpu/br25/audio_enc/audio_recorder_mix.c \
	cpu/br25/audio_enc/audio_sbc_codec.c \
	cpu/br25/audio_mic/effect_parm.c \
	cpu/br25/audio_mic/effect_reg.c \
	cpu/br25/audio_mic/loud_speaker.c \
	cpu/br25/audio_mic/mic_effect.c \
	cpu/br25/audio_mic/mic_stream.c \
	cpu/br25/audio_mic/simpleAGC.c \
	cpu/br25/audio_mic/vollevel_detect.c \
	cpu/br25/charge.c \
	cpu/br25/chargebox_hw.c \
	cpu/br25/chargestore.c \
	cpu/br25/clock_manager.c \
	cpu/br25/iic_eeprom_test.c \
	cpu/br25/iic_hw.c \
	cpu/br25/iic_slave_test.c \
	cpu/br25/iic_soft.c \
	cpu/br25/irflt.c \
	cpu/br25/led_spi.c \
	cpu/br25/ledc_test.c \
	cpu/br25/localtws/localtws.c \
	cpu/br25/localtws/localtws_dec.c \
	cpu/br25/mcpwm.c \
	cpu/br25/overlay_code.c \
	cpu/br25/plcnt.c \
	cpu/br25/port_wkup.c \
	cpu/br25/pwm_led.c \
	cpu/br25/setup.c \
	cpu/br25/spi.c \
	cpu/br25/spi_test.c \
	cpu/br25/uart_bt_product.c \
	cpu/br25/uart_dev.c \
	cpu/br25/uart_test.c \
	cpu/br25/ui_driver/LED_1888/LED1888.c \
	cpu/br25/ui_driver/interface/ui_platform.c \
	cpu/br25/ui_driver/lcd_seg/lcd_seg3x9_driver.c \
	cpu/br25/ui_driver/lcd_spi/lcd_drive.c \
	cpu/br25/ui_driver/lcd_spi/spi_oled.c \
	cpu/br25/ui_driver/led7/led7_driver.c \
	cpu/br25/ui_driver/led7_timer.c \
	cpu/br25/ui_driver/ui_common.c \


# 需要编译的 .S 文件
S_SRC_FILES := \
	apps/soundbox/sdk_version.z.S \


# 需要编译的 .s 文件
s_SRC_FILES :=


# 需要编译的 .cpp 文件
cpp_SRC_FILES :=


# 需要编译的 .cc 文件
cc_SRC_FILES :=


# 需要编译的 .cxx 文件
cxx_SRC_FILES :=


# 链接参数
LFLAGS := \
	--plugin-opt=-pi32v2-always-use-itblock=false \
	--plugin-opt=-enable-ipra=true \
	--plugin-opt=-pi32v2-merge-max-offset=4096 \
	--plugin-opt=-pi32v2-enable-simd=true \
	--plugin-opt=mcpu=r3 \
	--plugin-opt=-global-merge-on-const \
	--plugin-opt=-inline-threshold=5 \
	--plugin-opt=-inline-max-allocated-size=32 \
	--plugin-opt=-inline-normal-into-special-section=true \
	--plugin-opt=-dont-used-symbol-list=malloc,free,sprintf,printf,puts,putchar \
	--plugin-opt=save-temps \
	--plugin-opt=-pi32v2-enable-rep-memop \
	--sort-common \
	--dont-complain-call-overflow \
	--plugin-opt=-enable-movable-region=true \
	--plugin-opt=-movable-region-section-prefix=.movable.slot. \
	--plugin-opt=-movable-region-stub-section-prefix=.movable.stub. \
	--plugin-opt=-movable-region-prefix=.movable.region. \
	--plugin-opt=-movable-region-stub-prefix=__movable_stub_ \
	--plugin-opt=-movable-region-stub-swi-number=-2 \
	--plugin-opt=-movable-region-map-file-list=apps/soundbox/movable/funcname.txt \
	--plugin-opt=-movable-region-section-map-file-list=apps/soundbox/movable/section.txt \
	--plugin-opt=-movable-region-exclude-func-file-list=apps/soundbox/movable/exclude.txt \
	--plugin-opt=-used-symbol-file=cpu/br25/sdk_used_list.used \
	--gc-sections \
	--start-group \
	include_lib/liba/br25/cpu.a \
	include_lib/liba/br25/system.a \
	include_lib/liba/br25/libepmotion.a \
	include_lib/liba/br25/wtg_dec_lib.a \
	include_lib/liba/br25/sbc_eng_lib.a \
	include_lib/liba/br25/mp3tsy_dec_lib.a \
	include_lib/liba/br25/wtgv2_dec_lib.a \
	include_lib/liba/br25/flac_dec_lib.a \
	include_lib/liba/br25/ape_dec_lib.a \
	include_lib/liba/br25/m4a_tws_lib.a \
	include_lib/liba/br25/amr_dec_lib.a \
	include_lib/liba/br25/dts_dec_lib.a \
	include_lib/liba/br25/mp3_decstream_lib.a \
	include_lib/liba/br25/wma_decstream_lib.a \
	include_lib/liba/br25/libAptFilt_pi32v2_OnChip.a \
	include_lib/liba/br25/libEchoSuppress_pi32v2_OnChip.a \
	include_lib/liba/br25/libNoiseSuppress_pi32v2_OnChip.a \
	include_lib/liba/br25/libSplittingFilter_pi32v2_OnChip.a \
	include_lib/liba/br25/libDelayEstimate_pi32v2_OnChip.a \
	include_lib/liba/br25/libSingleMicSystem_pi32v2_OnChip.a \
	include_lib/liba/br25/compressor.a \
	include_lib/liba/br25/crossover_coff.a \
	include_lib/liba/br25/limiter.a \
	include_lib/liba/br25/lib_pitchshifter.a \
	include_lib/liba/br25/lib_pitch_speed.a \
	include_lib/liba/br25/lib_reverb_cal.a \
	include_lib/liba/br25/lib_mp2_code.a \
	include_lib/liba/br25/lib_adpcm_code.a \
	include_lib/liba/br25/mp3_enc_lib.a \
	include_lib/liba/br25/opus_enc_lib.a \
	include_lib/liba/br25/speex_enc_lib.a \
	include_lib/liba/br25/lib_rmono2stereo.a \
	include_lib/liba/br25/limiter_noiseGate.a \
	include_lib/liba/br25/howling.a \
	include_lib/liba/br25/noisegate.a \
	include_lib/liba/br25/shiftPhase.a \
	include_lib/liba/br25/pemafrow.a \
	include_lib/liba/br25/lib_howlings_phf.a \
	include_lib/liba/br25/lib_resample_cal.a \
	include_lib/liba/br25/lib_resample_fast_cal.a \
	include_lib/liba/br25/mp3_dec_lib.a \
	include_lib/liba/br25/wma_dec_lib.a \
	include_lib/liba/br25/wav_dec_lib.a \
	include_lib/liba/br25/agreement.a \
	include_lib/liba/br25/lib_sur_cal.a \
	include_lib/liba/br25/loudness.a \
	include_lib/liba/br25/filtparam_cal_lib.a \
	include_lib/liba/br25/media_app.a \
	include_lib/liba/br25/aec.a \
	include_lib/liba/br25/bt_hash_enc.a \
	include_lib/liba/br25/rcsp_stack.a \
	include_lib/liba/br25/lib_usbaudio_plc.a \
	include_lib/liba/br25/coeff_calculate.a \
	include_lib/liba/br25/rms.a \
	include_lib/liba/br25/SpectrumShow.a \
	include_lib/liba/br25/gma_stack.a \
	include_lib/liba/br25/dueros_stack.a \
	include_lib/liba/br25/tme_stack.a \
	include_lib/liba/br25/mma_stack.a \
	include_lib/liba/br25/lib_voiceChager.a \
	include_lib/liba/br25/drc.a \
	include_lib/liba/br25/DynamicEQ.a \
	include_lib/liba/br25/VirtualBass.a \
	apps/common/third_party_profile/tuya_protocol/sdk/lib/libtuya_lib.a \
	include_lib/liba/br25/lib_midi_dec.a \
	include_lib/liba/br25/btstack.a \
	include_lib/liba/br25/btctrler.a \
	include_lib/liba/br25/media.a \
	include_lib/liba/br25/libFFT_pi32v2_OnChip.a \
	include_lib/liba/br25/update.a \
	include_lib/liba/br25/res.a \
	include_lib/liba/br25/ui_dot.a \
	include_lib/liba/br25/font.a \
	include_lib/liba/br25/crypto_toolbox_Ospeed.a \
	include_lib/liba/br25/lib_cpu.a \
	--end-group \
	-Tcpu/br25/sdk.ld \
	-M=cpu/br25/tools/sdk.map \
	--plugin-opt=mcpu=r3 \
	--plugin-opt=-mattr=+fprev1 \


LIBPATHS := \
	-L$(SYS_LIB_DIR) \


LIBS := \
	$(SYS_LIB_DIR)/libm.a \
	$(SYS_LIB_DIR)/libc.a \
	$(SYS_LIB_DIR)/libm.a \
	$(SYS_LIB_DIR)/libcompiler-rt.a \



c_OBJS    := $(c_SRC_FILES:%.c=%.c.o)
S_OBJS    := $(S_SRC_FILES:%.S=%.S.o)
s_OBJS    := $(s_SRC_FILES:%.s=%.s.o)
cpp_OBJS  := $(cpp_SRC_FILES:%.cpp=%.cpp.o)
cxx_OBJS  := $(cxx_SRC_FILES:%.cxx=%.cxx.o)
cc_OBJS   := $(cc_SRC_FILES:%.cc=%.cc.o)

OBJS      := $(c_OBJS) $(S_OBJS) $(s_OBJS) $(cpp_OBJS) $(cxx_OBJS) $(cc_OBJS)
DEP_FILES := $(OBJS:%.o=%.d)


OBJS      := $(addprefix $(BUILD_DIR)/, $(OBJS))
DEP_FILES := $(addprefix $(BUILD_DIR)/, $(DEP_FILES))


VERBOSE ?= 0
ifeq ($(VERBOSE), 1)
QUITE :=
else
QUITE := @
endif

# 一些旧的 make 不支持 file 函数，需要 make 的时候指定 LINK_AT=0 make
LINK_AT ?= 1

# 表示下面的不是一个文件的名字，无论是否存在 all, clean, pre_build 这样的文件
# 还是要执行命令
# see: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: all clean pre_build

# 不要使用 make 预设置的规则
# see: https://www.gnu.org/software/make/manual/html_node/Suffix-Rules.html
.SUFFIXES:

all: pre_build $(OUT_ELF)
	$(info +POST-BUILD)
	$(QUITE) $(RUN_POST_SCRIPT) sdk

pre_build:
	$(info +PRE-BUILD)
	$(QUITE) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -D__LD__ -E -P cpu/br25/sdk_used_list.c -o cpu/br25/sdk_used_list.used
	$(QUITE) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -D__LD__ -E -P apps/soundbox/movable/section.c -o apps/soundbox/movable/section.txt
	$(QUITE) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -D__LD__ -E -P cpu/br25/sdk_ld.c -o cpu/br25/sdk.ld
	$(QUITE) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -D__LD__ -E -P cpu/br25/tools/download.c -o $(POST_SCRIPT)
	$(QUITE) $(FIXBAT) $(POST_SCRIPT)

clean:
	$(QUITE) $(RM) $(OUT_ELF)
	$(QUITE) $(RM) $(BUILD_DIR)



ifeq ($(LINK_AT), 1)
$(OUT_ELF): $(OBJS)
	$(info +LINK $@)
	$(shell $(MKDIR) $(@D))
	$(file >$(OBJ_FILE), $(OBJS))
	$(QUITE) $(LD) -o $(OUT_ELF) @$(OBJ_FILE) $(LFLAGS) $(LIBPATHS) $(LIBS)
else
$(OUT_ELF): $(OBJS)
	$(info +LINK $@)
	$(shell $(MKDIR) $(@D))
	$(QUITE) $(LD) -o $(OUT_ELF) $(OBJS) $(LFLAGS) $(LIBPATHS) $(LIBS)
endif


$(BUILD_DIR)/%.c.o : %.c
	$(info +CC $<)
	@$(MKDIR) $(@D)
	@$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -MM -MT $@ $< -o $(@:.o=.d)
	$(QUITE) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

$(BUILD_DIR)/%.S.o : %.S
	$(info +AS $<)
	@$(MKDIR) $(@D)
	@$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -MM -MT $@ $< -o $(@:.o=.d)
	$(QUITE) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

$(BUILD_DIR)/%.s.o : %.s
	$(info +AS $<)
	@$(MKDIR) $(@D)
	@$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -MM -MT $@ $< -o $(@:.o=.d)
	$(QUITE) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

$(BUILD_DIR)/%.cpp.o : %.cpp
	$(info +CXX $<)
	@$(MKDIR) $(@D)
	@$(CXX) $(CFLAGS) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -MM -MT $@ $< -o $(@:.o=.d)
	$(QUITE) $(CXX) $(CXXFLAGS) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

$(BUILD_DIR)/%.cxx.o : %.cxx
	$(info +CXX $<)
	@$(MKDIR) $(@D)
	@$(CXX) $(CFLAGS) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -MM -MT $@ $< -o $(@:.o=.d)
	$(QUITE) $(CXX) $(CXXFLAGS) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

$(BUILD_DIR)/%.cc.o : %.cc
	$(info +CXX $<)
	@$(MKDIR) $(@D)
	@$(CXX) $(CFLAGS) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -MM -MT $@ $< -o $(@:.o=.d)
	$(QUITE) $(CXX) $(CXXFLAGS) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

-include $(DEP_FILES)
